package com.cs.main;

import java.awt.Dimension;
import java.awt.Toolkit;

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTree;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.border.TitledBorder;

public class Main {
	boolean packFrame = false;
	public Main() {
		MainFrame frame = new MainFrame();
		if(packFrame){
			frame.pack();   //调整此窗口的大小，以适合其子组建的首选大小和布局
		}else{
			frame.validate();  //刷新窗体组件信息
		}
		Dimension scSize = Toolkit.getDefaultToolkit().getScreenSize();
		Dimension fSize = frame.getSize();  //设置窗体大小
		if(fSize.height > scSize.height){
			fSize.height = scSize.height;
		}
		if(fSize.width > scSize.width){
			fSize.width = scSize.width;
		}
		frame.setLocation((scSize.width - fSize.width) / 2,(scSize.height - fSize.height) / 2);
		frame.setVisible(false);
	}
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		SwingUtilities.invokeLater(new Runnable() {
			
			@Override
			public void run() {
				// TODO Auto-generated method stub
				try{
					UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
				}catch (Exception exception){
					exception.printStackTrace();
				}
				new Main();
				sale vendition = new sale();  //收银终端对象
				vendition.setVisible(true);   //设置为可见
				vendition.setTitle("超市收银终端"); //设置标题
			}
		});
	}
}
public class MainFrame extends JFrame{
	JPanel contentPane;
	/* 定义主菜单 */
	JMenuBar jMenuBar1 = new JMenuBar(); //定义菜单栏
	JMenu jMenu2 = new JMenu();          //仓库
	JMenu jMenu3 = new JMenu();			 //用户管理
	JMenu jMenu5 = new JMenu();			 //明细查询
	JMenu jMenu7 = new JMenu();		     //查询商品信息
	JMenu jMenu9 = new JMenu();          //按商品类别查询
	jMenu8.setText("系统");				
	
	//定义子菜单
	JMenuItem jMenuItem1 = new JMenuItem("退出系统"); //设置菜单名
	//jMenuItem1.setText("退出系统");
	JTree jTree1 = new JTree();/* 定义树形  */
	JLabel statusBar = new JLabel();//表格展示区域
	JScrollPane jScrollPane2 = new JScrollPane();//带滚动条的区域
	JTable jTable1 = new JTable();//表格
	TitledBorder titledBorder1 = new TitledBorder("");
	JScrollPane jScrollPane1 = new JScrollPane();//带滚动条的区域
	public MainFrame(){
		try{
			setDefaultCloseOperation(EXIT_ON_CLOSE);
			jbInit();
		}catch(Exception exception){
			exception.printStackTrace();
		}
	}
	private void jbInit() {
		// TODO Auto-generated method stub
		
	}

	jMenu8.add(jMenuItem1);  // 将子菜单加入父菜单
	jMenuBar1.add(jMenu8);   // 将父菜单加入菜单栏
}
